package com.dao;

import com.domain.EmpChargeActivity;
import com.utils.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class EmpChargeActivityDao {
    //创建jdbcTemplate对象
    private JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUtils.getDataSource());

    /**
     * 根据员工的id查询所有职责分工
     * @param employeeId 传入Integer类型的员工Id
     * @return 返回List类型的EmpChargeActivity对象数据
     */
    public List<EmpChargeActivity> FindECA(Integer employeeId){
        String sql="SELECT * FROM actcharge c ,employee e,activity a WHERE c.employeeid=? and c.employeeid=e.employeeid and c.activityid=a.activityid";
        List<EmpChargeActivity> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(EmpChargeActivity.class), employeeId);
        return list;
    }
}
